<?php

namespace App\Console\Commands;

use App\Http\Services\LuckDrawServices;
use Carbon\Carbon;
use Illuminate\Console\Command;

class CommandSendUniverseAwardWeek extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'CommandSendUniverseAwardWeek';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '发放每周奖励';

    protected $activityService;
    protected $log = 'SendUniverseAwardWeek';
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
        $this->activityService = new LuckDrawServices();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        //获取上周时间
        $startWeek = Carbon::yesterday()->startOfWeek()->toDateString();
        $endWeek = Carbon::yesterday()->endOfWeek()->toDateString();
        //发放
        $res = $this->activityService->sendWeekAward($startWeek, $endWeek);
        write_log($this->log,'INFO 每周发放星辰奖励',$res);
    }
}